package com.ruoyi.jihuo.api.official;

import com.ruoyi.jihuo.api.ApiStrategy;
import com.ruoyi.jihuo.domain.JhTmAccount;
import com.taobao.top.BaseTopApiRequest;
import com.taobao.top.BaseTopApiResponse;
import com.taobao.top.TopApiClient;
import com.taobao.top.ability648.Ability648;
import com.taobao.top.ability648.request.TaobaoDeliveryTemplatesGetRequest;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

@Component
public class TaobaoDeliveryTemplatesGetStrategy implements ApiStrategy {
    @Override
    public BaseTopApiResponse execute(TopApiClient client, BaseTopApiRequest request, JhTmAccount jhTmAccount) throws IOException {
        Ability648 apiPackage = new Ability648(client);
        return apiPackage.taobaoDeliveryTemplatesGet((TaobaoDeliveryTemplatesGetRequest ) request, jhTmAccount.getJhAppSession());
    }

    @Override
    public BaseTopApiRequest setParams(String api, Map<String, Object> paramMap) {
        TaobaoDeliveryTemplatesGetRequest  request = new TaobaoDeliveryTemplatesGetRequest ();
        ArrayList fields = new ArrayList<String>() {{
            add("template_id");
            add("template_name");
            add("created");
            add("modified");
            add("supports");
            add("assumer");
            add("valuation");
            add("query_express");
            add("query_ems");
            add("query_cod");
            add("query_post");
        }};
        request.setFields(fields);
        return request;
    }
}
